$( document ).ready(function(){
    $('.page.active').css('visibility', 'hidden');
	$('#PageIdCat').on('change', function(){
		var me = $(this);
		$.post(
			me.data('url'),
			{ id_cat: me.val() },
			function(data){
				var options = '<option value="">(Aucun)</option>';
				for(var i=0;i<data['subcats'].length;i++){
					options += '<option value="' + data['subcats'][i].id + '">' + data['subcats'][i].name + '</option>';
				}
				var selectSubcat = $('#PageIdSubcat');
				if(data['subcats'].length > 0){
					$('#PageIdSubcat').html(options).removeAttr('disabled');
				}
				else
					$('#PageIdSubcat').attr('disabled', 'disabled');					
			});
	});

    $('#picker').colpick({layout:'hex'});
});